﻿using System;
using UnityEngine;

public class EditScrollSelectUI : MonoBehaviour
{
    public ScrollSelectUI scrollSelectUI;

    public string[] values;

    int m_curIndex;

    public Action<int,string> onEditEnd;

    public virtual void OnEnable()
    {
        scrollSelectUI.ResetPos();
        scrollSelectUI.onIndex = OnScrollIndex;
    }

    public virtual void Start()
    {
        scrollSelectUI.Init(values);
    }

    private void OnScrollIndex(int obj)
    {
        m_curIndex = obj;
    }


    public void OnClickConfirm()
    {
        string value = m_curIndex < values.Length ? values[m_curIndex] : "";
        onEditEnd?.Invoke(m_curIndex, value);
    }

}
